class Solution {
public:
    int waysToStep(int n)
    {
        int Mod = 1e9 + 7;
        if (n == 1 || n == 2)
            return n;
        if (n == 3)
            return 4;
        vector<int> d(n + 1);
        d[1] = 1, d[2] = 2, d[3] = 4;
        for (int i = 4; i <= n; i++)
        {
            d[i] = ((d[i - 1] + d[i - 2]) % Mod + d[i - 3]) % Mod;
        }
        return d[n];
    }
};